import 'package:flutter/material.dart';
import 'package:wayofdressing/contraints.dart';
import 'package:wayofdressing/components/bigbutton.dart';
import 'package:wayofdressing/components/singlechildbutton.dart';
import 'package:wayofdressing/screens/community_screen.dart';
import 'package:wayofdressing/screens/raise_screen.dart';
import 'package:wayofdressing/screens/store_screen.dart';
import 'package:wayofdressing/components/inmenubutton.dart';

class ExploreScreen extends StatelessWidget {
  static final String id = 'explorescreen';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xfffffaf0),
      appBar: AppBar(
        backgroundColor: Color(0xfffffaf0),
        elevation: 0,
        toolbarHeight: 80,
        leadingWidth: 200,
        leading: Row(
          children: [
            SizedBox(
              width: 20,
            ),
            MenuAnchor(
              menuChildren: [
                InMenuButton(
                  text: '待开发',
                  onPressed: () {},
                ),
              ],
              style: MenuStyle(
                alignment: Alignment(-0.7, 1),
                shape: MaterialStateProperty.all(
                  RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(25),
                  ),
                ),
                padding: MaterialStateProperty.all(EdgeInsets.all(15.0)),
                shadowColor: MaterialStateProperty.all(Colors.transparent),
                backgroundColor: MaterialStateProperty.all(
                  Colors.black.withOpacity(0.4),
                ),
              ),
              builder: (BuildContext context, MenuController controller,
                  Widget? child) {
                return GestureDetector(
                  onTap: () {
                    if (controller.isOpen) {
                      controller.close();
                    } else {
                      controller.open();
                    }
                  },
                  child: Icon(
                    Icons.list_rounded,
                    size: kAppBarButtonSize,
                    color: Colors.black,
                  ),
                );
              },
            ),
          ],
        ),
        actions: [
          Row(
            children: [
              MenuAnchor(
                menuChildren: [
                  InMenuButton(
                    onPressed: () {},
                    text: '待开发',
                    alignment: Alignment.centerRight,
                  ),
                ],
                style: MenuStyle(
                  shape: MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(25.0),
                    ),
                  ),
                  alignment: Alignment(-3, 1),
                  padding: MaterialStateProperty.all(EdgeInsets.all(15.0)),
                  shadowColor: MaterialStateProperty.all(Colors.transparent),
                  backgroundColor: MaterialStateProperty.all(
                    Colors.black.withOpacity(0.4),
                  ),
                ),
                builder: (BuildContext context, MenuController controller,
                    Widget? child) {
                  return GestureDetector(
                    onTap: () {
                      if (controller.isOpen) {
                        controller.close();
                      } else {
                        controller.open();
                      }
                    },
                    child:Row(
                      children: [
                        CircleAvatar(
                          backgroundImage: AssetImage('images/peanut.jpg'),
                          radius: 22,
                          backgroundColor: Colors.black,
                        ),
                      ],
                    ),
                  );
                },
              ),
            ],
          ),
          SizedBox(
            width: 20,
          )
        ],
      ),
      body: Row(
        children: [
          SizedBox(
            width: 20,
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Container(
                  height: 30,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Text(
                        '今日',
                        style: TextStyle(
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 24,
                        ),
                      )
                    ],
                  ),
                ),
                singleChildButton(
                  onPressed: (){},
                  flexNumber: 35,
                  childWidget: Text(
                    '推送/组件',
                    style: TextStyle(
                      fontSize: 32,
                      fontWeight: FontWeight.bold,
                      color: Colors.black,
                    ),
                  ),
                ),
                Expanded(
                  flex: 55,
                  child: Row(
                    children: [
                      bigButton(
                        onPressed: () {
                          Navigator.pushNamed(context, CommunityScreen.id);
                        },
                        buttonIcon: Icon(
                          Icons.castle_outlined,
                          size: kBigButtonSize,
                        ),
                        text: '社区',
                      ),
                      bigButton(
                        onPressed: () {
                          Navigator.pushNamed(context, RaiseScreen.id);
                        },
                        buttonIcon: Icon(
                          Icons.diversity_3_rounded,
                          size: kBigButtonSize,
                        ),
                        text: '募集',
                      ),
                    ],
                  ),
                ),
                bigButton(
                  onPressed: () {
                    Navigator.pushNamed(context, StoreScreen.id);
                  },
                  flexNumber: 35,
                  buttonIcon: Icon(
                    Icons.currency_exchange_rounded,
                    size: kBigButtonSize,
                  ),
                  text: '卖场',
                ),
              ],
            ),
          ),
          SizedBox(
            width: 20,
          )
        ],
      ),
    );
  }
}
